﻿using System;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.UI;

// Token: 0x020003A5 RID: 933
public class InputSliderUI : MonoBehaviour
{
	// Token: 0x1700023F RID: 575
	// (get) Token: 0x06001733 RID: 5939 RVA: 0x0009B48C File Offset: 0x0009968C
	// (set) Token: 0x06001734 RID: 5940 RVA: 0x0009B494 File Offset: 0x00099694
	public float Value
	{
		get
		{
			return this.value;
		}
		set
		{
			this.SetValue(value);
		}
	}

	// Token: 0x17000240 RID: 576
	// (get) Token: 0x06001735 RID: 5941 RVA: 0x0009B4A0 File Offset: 0x000996A0
	public bool IsHandling
	{
		get
		{
			return this.slider.IsHandling;
		}
	}

	// Token: 0x17000241 RID: 577
	// (get) Token: 0x06001736 RID: 5942 RVA: 0x0009B4B0 File Offset: 0x000996B0
	// (set) Token: 0x06001737 RID: 5943 RVA: 0x0009B4B8 File Offset: 0x000996B8
	public bool Intaractable
	{
		get
		{
			return this.intaractable;
		}
		set
		{
			this.intaractable = value;
			this.slider.interactable = value;
			this.inputField.interactable = value;
			this.defButton.interactable = value;
			if (this.noIntaractImage != null)
			{
				this.noIntaractImage.enabled = !value;
			}
		}
	}

	// Token: 0x06001738 RID: 5944 RVA: 0x0009B510 File Offset: 0x00099710
	private void Start()
	{
		this.SetDefPos();
	}

	// Token: 0x06001739 RID: 5945 RVA: 0x0009B518 File Offset: 0x00099718
	private void Update()
	{
	}

	// Token: 0x0600173A RID: 5946 RVA: 0x0009B51C File Offset: 0x0009971C
	public void SetTitle(string str)
	{
		this.title.text = str;
	}

	// Token: 0x0600173B RID: 5947 RVA: 0x0009B52C File Offset: 0x0009972C
	public void SetValue(float val)
	{
		this.OnChanged(val, false);
	}

	// Token: 0x0600173C RID: 5948 RVA: 0x0009B538 File Offset: 0x00099738
	public void ChangeSlider(float val)
	{
		if (!this.invoke)
		{
			return;
		}
		this.OnChanged(val, true);
	}

	// Token: 0x0600173D RID: 5949 RVA: 0x0009B550 File Offset: 0x00099750
	public void ChangeInputField(string val)
	{
		if (!this.invoke)
		{
			return;
		}
		float val2 = 0f;
		try
		{
			val2 = float.Parse(val);
		}
		catch
		{
		}
		this.OnChanged(val2, true);
	}

	// Token: 0x0600173E RID: 5950 RVA: 0x0009B59C File Offset: 0x0009979C
	private void OnChanged(float val, bool invokeAction = true)
	{
		this.invoke = false;
		this.value = Mathf.Clamp(val, this.slider.minValue, this.slider.maxValue);
		this.slider.value = this.value;
		this.inputField.text = this.value.ToString(this.textFormat);
		if (invokeAction && this.onChangeAction != null)
		{
			this.onChangeAction.Invoke(this.value);
		}
		this.invoke = true;
	}

	// Token: 0x0600173F RID: 5951 RVA: 0x0009B628 File Offset: 0x00099828
	public void ResetDef()
	{
		this.value = this.defVal;
		if (!this.invoke)
		{
			return;
		}
		this.OnChanged(this.defVal, true);
	}

	// Token: 0x06001740 RID: 5952 RVA: 0x0009B650 File Offset: 0x00099850
	public void Setup(float min, float max, bool hasDef, float defVal)
	{
		this.slider.minValue = min;
		this.slider.maxValue = max;
		this.hasDef = hasDef;
		this.defVal = defVal;
		this.SetDefPos();
	}

	// Token: 0x06001741 RID: 5953 RVA: 0x0009B680 File Offset: 0x00099880
	public void Setup(string title, float min, float max, bool hasDef, float defVal, UnityAction<float> onChange)
	{
		this.title.text = title;
		this.slider.minValue = min;
		this.slider.maxValue = max;
		this.hasDef = hasDef;
		this.defVal = defVal;
		if (onChange != null)
		{
			this.onChangeAction.AddListener(onChange);
		}
		this.SetDefPos();
	}

	// Token: 0x06001742 RID: 5954 RVA: 0x0009B6DC File Offset: 0x000998DC
	private void SetDefPos()
	{
		this.defButton.gameObject.SetActive(this.hasDef);
		if (this.hasDef)
		{
			RectTransform rectTransform = this.defButton.transform as RectTransform;
			RectTransform rectTransform2 = rectTransform.parent as RectTransform;
			float num = Mathf.InverseLerp(this.slider.minValue, this.slider.maxValue, this.defVal);
			float num2 = rectTransform2.rect.xMax - rectTransform2.rect.xMin;
			Vector3 v = rectTransform.anchoredPosition;
			v.x = num2 * num;
			rectTransform.anchoredPosition = v;
		}
	}

	// Token: 0x06001743 RID: 5955 RVA: 0x0009B790 File Offset: 0x00099990
	private void OnValidate()
	{
		this.SetDefPos();
	}

	// Token: 0x06001744 RID: 5956 RVA: 0x0009B798 File Offset: 0x00099998
	public EventTrigger GetEventTrigger()
	{
		EventTrigger component = base.GetComponent<EventTrigger>();
		if (component)
		{
			return component;
		}
		return base.gameObject.AddComponent<EventTrigger>();
	}

	// Token: 0x06001745 RID: 5957 RVA: 0x0009B7C4 File Offset: 0x000999C4
	public void AddEventEntry(EventTrigger.Entry entry)
	{
		EventTrigger eventTrigger = this.GetEventTrigger();
		eventTrigger.triggers.Add(entry);
	}

	// Token: 0x06001746 RID: 5958 RVA: 0x0009B7E4 File Offset: 0x000999E4
	public void AddOnChangeAction(UnityAction<float> action)
	{
		this.onChangeAction.AddListener(action);
	}

	// Token: 0x04001AE9 RID: 6889
	[SerializeField]
	private Text title;

	// Token: 0x04001AEA RID: 6890
	[SerializeField]
	private string textFormat = "0.00";

	// Token: 0x04001AEB RID: 6891
	[SerializeField]
	private CheckableSlider slider;

	// Token: 0x04001AEC RID: 6892
	[SerializeField]
	private InputField inputField;

	// Token: 0x04001AED RID: 6893
	[SerializeField]
	private bool hasDef;

	// Token: 0x04001AEE RID: 6894
	[SerializeField]
	private float defVal;

	// Token: 0x04001AEF RID: 6895
	[SerializeField]
	private Button defButton;

	// Token: 0x04001AF0 RID: 6896
	[SerializeField]
	private Image noIntaractImage;

	// Token: 0x04001AF1 RID: 6897
	private bool invoke = true;

	// Token: 0x04001AF2 RID: 6898
	private float value;

	// Token: 0x04001AF3 RID: 6899
	[SerializeField]
	private InputSliderUI.OnChangeAction onChangeAction;

	// Token: 0x04001AF4 RID: 6900
	private bool intaractable = true;

	// Token: 0x020003A6 RID: 934
	[Serializable]
	public class OnChangeAction : UnityEvent<float>
	{
	}
}
